Section |
---|
Introduction - Gradle vs Scripts - Gradle vs Maven - Summary |
Context Model - External Entities - Interactions |
Gradle is a build automation tool written in Java and runs on the Java Virtual Machine. Within the context of software development, building refers to the process of converting source code into executables (and other artifacts).
Gradle offers a set of configuration script files which can be configured to dictate build behavior. These files may define tasks, which are executable pieces of code. They can further apply plugins which can add more tasks or modify a project's configuration at run-time.
Plugins are a direct consequence of both Gradle's architectural principle #1 and its flexibility concerns.
As evidenced by plugins, Gradle follows a microkernel architectural style. On the other hand, tasks are derived from the command design pattern.
While it is possible for developers to write their own script files to build their projects, such simple scripts are often rigid and lacking in features. A change in the project's structure may require the scripts to be completely rewritten.
Writing scripts to automate the building process of complex software is a time consuming endeavor. On the other hand, configuring Gradle to build complex software is simpler and less time consuming.
Gradle allows developers to save time by "sharing code" via plugins. It also has the ability to download missing dependencies, run automated tests or even custom tasks.
Maven is another build automation tool and is Gradle's main competitor. Gradle is architectured to be both faster and more flexible than Maven.
Maven uses a simple and easy to grasp language, XML, to define its build configuration. Gradle uses Java-like languages, Groovy and Kotlin, to define its build configuration. This allows Gradle to be more flexible than Maven.
It outperforms Maven thanks to the combination of the gradle daemon, incremental builds and the build cache.
Gradle is a build automation tool that:
Entity | Description |
---|---|
Project Developers | These are Gradle's typical users. They are software developers tasked with writing the software entity depicted in the model. Their main interaction with Gradle would be the execution of a build task. |
Plugin Developers | These are Gradle users or Gradle developers who are usually more familiar with Gradle. They extend Gradle's functionality by writing plugins and making them publicly available. |
Repository | Refers to (usually remote) storage which facilitates the download and upload of software packages. Examples include GitHub, Maven Repository, and Gradle Plugin Repository. |
Software | This is the software Gradle is tasked with building. It may be comprised of a single or multiple projects. This respresents the software's source code and other artifacts relevant to the building process. The software is written by the Project Developers. |
Project developers mainly run build tasks. Upon execution, this task typically automatically downloads missing dependencies, compiles the code, runs tests, etc...
For the build task to exhibit the desired build behavior project developers would have to first setup the build automation process. To do this, they would add the appropriate plugins and tasks to each project's build script file. They would also configure Gradle's general settings and properties.
Once the automation setup is complete, they usually make small configuration changes such as modifying the value of a property in the gradle.properties file(s) or modfiying a project's configuration. The difference between these configuration changes and the changes made during the automation setup is simply their scale.
Plugin developers write Java/Kotlin/Groovy classes and make them publicly available. These plugins are used to extend Gradle's functionality. Plugin developers upload their class/plugin to a repository such as GitHub and register their plugin to Gradle's plugin repository which is used for indexing (e.g. plugin name -> GitHub url).
Project developers may want to apply a plugin to a project. To do this, they simply include the plugin name under the project's configuration script file. Gradle defines a resolution process to download the plugin from the appropriate source (e.g. Github).
More information on Plugins can be found in the functional view and information view.
Repositories contain information relevant to the build process, this could be missing project dependencies, missing plugins or simply a url (e.g. the Gradle Plugin Repository is used to index plugin names to the urls where they can be found).
Refers to the software being developed by the Project Developers. The software may follow a single-project or multi-project structure. Gradle enables each project to be built, compiled, tested, etc... Project Developers can specify the build behavior desired for a particular software by modifying each of the software's projects configuration script files.